function ImageManager(){
	this.images = new Array();
	
	this.add = function(name,url){
		if(!url) url = name;
		var img = new ImageHandler(name,url);
		this.images.push(img);
	}
	
	this.get = function(name){
		// try to find an image by name
		for(var i=0;i<this.images.length;i++){
			if(this.images[i].name==name) return this.images[i];
		}
		// we did not find the image by name
		// try finding it by url
		for(var i=0;i<this.images.length;i++){
			if(this.images[i].url==name) return this.images[i];
		}
		// we did not find the image by name or url
		return null;
	}
}

function ImageHandler(name,url){
	this.name = name;
	this.image = new Image();
	this.url = url;
	this.loaded = false;
	var self = this;
	this.image.onload = function(){
		self.loaded = true;
	}
	this.image.src = url;
}